import { defineStore } from 'pinia'
import { Names } from './store-name'

// 完整创建
export const useTestStore = defineStore(Names.TEST, {
    state: () => { // 类型自动推导
        return {
            name: '创建一个测试Store',
            count: 1,
        }
    },
    // 类似 computed
    getters: {
        preName(): string {
            return 'pre' + this.name
        },
    },
    // 同步 + 异步
    actions: {
        setName(name: string) {
            this.name = name;
        }
    }
})